package com.moensun.akka.springboot.akka;

import akka.actor.AbstractExtensionId;
import akka.actor.ExtendedActorSystem;
import akka.actor.Extension;
import akka.actor.Props;
import org.springframework.context.ApplicationContext;

/**
 * Created by Bane.Shi.
 * Copyright MoenSun
 * User: Bane.Shi
 * Date: 2017/3/8
 * Time: 15:34
 */
public class SpringExtension extends AbstractExtensionId<SpringExtension.SpringExt> {

	public static SpringExtension SpringExtProvider = new SpringExtension();

	public SpringExt createExtension(ExtendedActorSystem extendedActorSystem) {
		return new SpringExt();
	}


	public static class SpringExt implements Extension {
		private volatile ApplicationContext applicationContext;

		public void initialize(ApplicationContext applicationContext) {
			this.applicationContext = applicationContext;
		}

		public Props props(String actorBeanName) {
			return Props.create(SpringActorProducer.class,applicationContext,actorBeanName);
		}

	}

}
